package com.dom.domweb.modular.controller.sysmger;

import com.dom.common.model.vo.basic.B010R;
import com.dom.common.model.vo.basic.B013A;
import com.dom.common.model.vo.basic.B019A;
import com.dom.common.model.vo.basic.B019R;
import com.dom.domweb.common.RspModel;
import com.dom.domweb.common.TabPager;
import com.dom.domweb.dao.service.ITSuppInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 供应商控制器
 * @author zhuwei
 * @Date 2018-11-17
 */
@RestController
@RequestMapping("/base")
public class SupplierController {
    
    @Autowired
    private ITSuppInfoService suppInfoService;

    @RequestMapping("/getSupplierInfoList")
    public TabPager getSupplierInfoList(@RequestParam("limit")int limit, @RequestParam("page")int page, @RequestParam("abbrName")String abbrName){
        B019R request = new B019R();
        request.setPn(page);
        request.setPs(limit == 0 ? 20 : limit);
        request.setAbbrname(abbrName);
        B019A result = suppInfoService.getSupplierInfoList(request);
        return new TabPager(result.getSuppInfoData(),result.getTotalNum());
    }

    @RequestMapping("/getAllSupplierInfo")
    public RspModel getAllSupplierInfo(){
        B019A result = suppInfoService.getAllSupplierInfo();
        return new RspModel(result.getSuppInfoData());
    }

    @RequestMapping("/getSupplierInfoByCode")
    public RspModel getSupplierInfoByCode(@RequestParam("id") String id){
        B013A result = suppInfoService.getSupplierInfoByCode(id);
        return new RspModel(result);
    }
    @RequestMapping("/insertSupplierInfo")
    public RspModel insertSupplierInfo(@RequestBody B010R request){
        return suppInfoService.insertSupplierInfo(request);
    }

    @RequestMapping("/updateSupplierInfo")
    public RspModel editSupplierInfo(@RequestBody B010R request){
        return suppInfoService.editSupplierInfo(request);
    }

    @RequestMapping("/supplierInfoDel")
    public RspModel supplierInfoDel(@RequestParam("id")String id){
        return suppInfoService.supplierInfoDel(id);
    }
}
